import axios from  'axios'
import  store  from '../../store'
let http=axios.create({

  baseURL:'/api'
    
})

//axios的拦截器
//请求拦截
http.interceptors.request.use((req)=>{
    //给购物车接口添加请求头
    if(store.getters.getUserInfo){
        req.headers.authorization = store.getters.getUserInfo.token
    }
    return req
})

http.interceptors.response.use((res)=>{
 
  return  res.data
})

export default  http